﻿using System;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Auditing;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Repositories;

namespace Volo.Abp.Application.Services
{

    public abstract class ReadOnlyAppService<TEntity, TEntityDto, TKey>
        : ReadOnlyAppService<TEntity, TEntityDto, TEntityDto, TKey>
        where TEntity : class, IEntity<TKey>
    {
        protected ReadOnlyAppService(IReadOnlyRepository<TEntity, TKey> repository)
            : base(repository)
        {

        }
    }

    public abstract class ReadOnlyAppService<TEntity, TGetOutputDto, TGetListOutputDto, TKey>
        : AbstractKeyReadOnlyAppService<TEntity, TGetOutputDto, TGetListOutputDto, TKey>
        where TEntity : class, IEntity<TKey>
    {
        protected IReadOnlyRepository<TEntity, TKey> Repository { get; }

        protected ReadOnlyAppService(IReadOnlyRepository<TEntity, TKey> repository)
        : base(repository)
        {
            Repository = repository;
        }

        protected override async Task<TEntity> GetEntityByIdAsync(TKey id)
        {
            return await Repository.GetAsync(id);
        }

    }
}
